package com.itfreer.bpm.workflow.service.disposal;

import java.util.HashMap;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.itfreer.bpm.history.entity.BpmHistoryEntity;
import com.itfreer.bpm.workflow.utils.BpmHistoryQueryUtil;
/**
 * 查询流程服务是否退件
 * @author gj
 *
 */
@Component
public class BpmWorkFlowDisposeQuery {
	private final static String optionName="退件";
	/**
	 * 审批过程查询接口
	 */
	@Autowired
	BpmHistoryQueryUtil historyQueryUtil;
	/**
	 * 查询流程服务是否已经被退件
	 * @param sexeId
	 * @return
	 */
	public boolean queryFlowDispose(String sexeId) {
		HashMap<String,Object> overwork_where=new HashMap<String,Object>();
		overwork_where.put("sexeid:=",sexeId);
		List<BpmHistoryEntity> overWrokH=historyQueryUtil.getOverWorkEntitys(null, overwork_where, null, 1, 1);
		if(overWrokH==null || overWrokH.size()<1) return true;
		if(optionName.equals(overWrokH.get(0).getoptresult())) return true; //项目状态等于退件标识为退件项目
		if("T9".equals(overWrokH.get(0).gettaskdefid())
				|| "U9".equals(overWrokH.get(0).gettaskdefid())) {
			return true;//项目在T9状态和U9状态统一标识为退件项目
		}
		return false;
	}
}
